package com.kee.server.manager.service;

import com.kee.common.util.RegxUtil;
import com.kee.share.bean.Exam;

public class PushChoice implements PushPlugin {

	private final static String MAIN_DIV_CSS = "<div class=\"pt1\" style=\"margin: 0px; padding: 0px; overflow: hidden; zoom: 1; clear: both; line-height: 25px; color: rgb(0, 0, 0); font-family: 宋体, sans-serif; font-size: 13px; letter-spacing: 1px;\">";
	
	private Exam exam;
	
	public PushChoice(Exam exam){
		this.exam = exam;
	}
	
	public String buildContentTxtHTML(Object obj) throws Exception {
		Exam exam = (Exam)obj;
		StringBuilder sb = new StringBuilder();
		sb.append(MAIN_DIV_CSS);
		sb.append("<div>");
		//题目内容
		sb.append("<div>");
		sb.append("<span style='color:#F87219;'>题目:</span>");
		sb.append(exam.getExam());
		sb.append("</div>");
		//选项
		for (int i = 65; i <= 68; i++) {
			String g = RegxUtil.UBBParser(exam.getOpts(), String.valueOf((char) i));
			sb.append("<div>");
			sb.append(g);
			sb.append("</div>");
		}
		//分析
		sb.append("<div>");
		sb.append("&nbsp");
		sb.append("</div>");
		sb.append("<div>");
		sb.append("<span style='color:#F87219;'>解析:</span>");
		sb.append(exam.getAnaly());
		sb.append("</div>");
		sb.append("<div>");
		sb.append(exam.getExplains());
		sb.append("</div>");
		//答案
		sb.append("<div>");
		sb.append("&nbsp");
		sb.append("</div>");
		sb.append("<div>");
		sb.append("<span style='color:#F87219;'>答案:</span>");
		sb.append(exam.getAnswer());
		sb.append("</div>");
		//知识点
		sb.append("<div>");
		sb.append("&nbsp");
		sb.append("</div>");
		sb.append("<div>");
		sb.append("<span style='color:#F87219;'>知识点:</span>");
		sb.append(exam.getKnowledge());
		sb.append("</div>");
		
		//结束div
		sb.append("</div>");
		sb.append("</div>");
		return sb.toString();
	}


	public String getAnalyze() {
		StringBuilder sb = new StringBuilder();
		if (exam.getAnaly() != null) {
			sb.append("<div>");
			sb.append("&nbsp");
			sb.append("</div>");
			sb.append("<div>");
			sb.append("<span>解析:</span>");
			sb.append(RegxUtil.NoteEscapeParser(exam.getAnaly()));
			sb.append("</div>");
		}
		if (exam.getExplains() != null) {
			sb.append("<div>");
			sb.append(RegxUtil.NoteEscapeParser(exam.getExplains()));
			sb.append("</div>");
		}
		//答案
		if (exam.getAnswer() != null) {
			sb.append("<div>");
			sb.append("&nbsp");
			sb.append("</div>");
			sb.append("<div>");
			sb.append("<span>答案:</span>");
			sb.append(RegxUtil.NoteEscapeParser(exam.getAnswer()));
			sb.append("</div>");
		}
		//知识点
		if (exam.getKnowledge() != null) {
			sb.append("<div>");
			sb.append("&nbsp");
			sb.append("</div>");
			sb.append("<div>");
			sb.append("<span>知识点:</span>");
			sb.append(exam.getKnowledge());
			sb.append("</div>");
		}
		return sb.toString();
	}


	public String getTitle() throws Exception {
		String title = RegxUtil.NoteEscapeParser(exam.getExam());
		StringBuilder sb = new StringBuilder();
		sb.append("<div>");
		//题目内容
		sb.append("<div>");
		sb.append(title);
		sb.append("</div>");
		//选项
		for (int i = 65; i <= 68; i++) {
			String g = RegxUtil.UBBParser(exam.getOpts(), String.valueOf((char) i));
			sb.append("<div>");
			sb.append(g);
			sb.append("</div>");
		}
		//结束div
		sb.append("</div>");
		return sb.toString();
	}

}
